package com.secure.sample.feign;

import com.secure.annotation.ApiSecure;
import com.secure.enums.ResponseDecryptEnum;
import com.secure.sample.api.BaseResponse;
import com.secure.sample.vo.UserGetDetailVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author duchao
 */
@FeignClient(name = "sampleService",url = "http://localhost:8080",path = "test")
public interface TestFeign {

    @ApiSecure(decryptResponse = ResponseDecryptEnum.DECRYPT)
    @RequestMapping(value = "xWwwFormUrlencoded1",method = RequestMethod.POST,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    BaseResponse<Map<String, Object>> xWwwFormUrlencoded1(@RequestParam("id") Integer id, @RequestParam("name") String name);

    //@ApiSecure(decryptResponse = false)
    @RequestMapping(value = "xWwwFormUrlencoded2",method = {RequestMethod.GET},consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    //BaseResponse<String> xWwwFormUrlencoded2(@RequestBody String content);
    BaseResponse xWwwFormUrlencoded2(String content);

    @ApiSecure(decryptResponse = ResponseDecryptEnum.DECRYPT)
    @PostMapping(value = "json1",consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<UserGetDetailVO> json1(UserGetDetailVO vo);

    @ApiSecure(decryptResponse = ResponseDecryptEnum.DECRYPT)
    @PostMapping(value = "json2",consumes = MediaType.APPLICATION_JSON_VALUE)
    BaseResponse<String> json2(@RequestBody String content);

    @ApiSecure(decryptResponse = ResponseDecryptEnum.DECRYPT)
    @PostMapping(value = "text1",consumes = MediaType.TEXT_PLAIN_VALUE)
    BaseResponse<String> text1(@RequestBody String content);

    @ApiSecure(decryptResponse = ResponseDecryptEnum.DECRYPT)
    @PostMapping(value = "form1",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    BaseResponse<Map<String, Object>> form1(@RequestParam("id") Integer id,@RequestParam("name") String name);

    @ApiSecure(decryptResponse = ResponseDecryptEnum.DECRYPT)
    @GetMapping(value = "query",consumes = MediaType.ALL_VALUE)
    BaseResponse<Map<String, Object>> query(@RequestParam("id") Integer id,@RequestParam("name") String name);
}
